package hn.cch.service.impl;

import hn.cch.entity.User;
import hn.cch.repository.UserRepository;
import hn.cch.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Optional;

@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserRepository userRepository;

    public User findById(Integer id){
        Optional<User> optional = userRepository.findById(id);
        return optional.isPresent() ? optional.get() : null;
    }

    public User save(User user){
        return userRepository.save(user);
    }
}
